import Vue  from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)

export default new Vuex.Store({
    state: {
       show:"首页",
       p_id:'',
       p_num:1,
       Newtext:[{
         user:'高生',
         content:'捐出一本《java从入门到放弃》',
         count_zan:'',
         count_collect:'',
       }],
        new_pinglun:[{
            n_name:'高生',
            n_pinglun:'说实话，评论功能真是又丑又难做'

        }],
       username:'游客',
       qwe: []
    },
    getters: {
       
    },
    mutations: {
        changeStatus (state,myId) {
            state.show=myId;
        },
        addNewtext (state,obj){
            state.Newtext.unshift(obj);
            state.p_num++
        },
        addpinglun (state,obj_pinglun){ 
            state.new_pinglun.push(obj_pinglun)    
        },
       
       increment1 (state,index) {
            state.Newtext[index].count_zan++
        },
        increment2 (state,index) {
            state.Newtext[index].count_collect++
        },
        changename (state,obj_name) {
            state.username=obj_name;
        },
        ceshi(state,obj_name_mima){
         state.qwe.push(obj_name_mima)
        }
    },
    actions: {
       increment ({ commit }) {
            commit('increment')
       }
    }
})